package gstring{
	//import components.finger;
	import components.gString;
	
	import mx.containers.Canvas;
	import mx.effects.Rotate;
	
	import spark.components.supportClasses.ItemRenderer;
	import spark.core.SpriteVisualElement;
	import spark.effects.Rotate3D;
	import spark.effects.easing.IEaser;
	import spark.effects.easing.Linear;
	
	public class guitarstring{
		private var _num:int;
		[Bindable]
		private var _strings:Array;
		public function guitarstring(num:int){
			_num=num;
			_strings = new Array();
			createStrings();
		}
		private function createStrings():void{
			for(var i:int=0; i<_num; i++){
				_strings.push(new gString() as SpriteVisualElement);
				
				if(i == 0){
					_strings[i].visible = true;
				}else{
					_strings[i].visible = false;
				}
				if(i%2 == 1){
					_strings[i].scaleY = -1;
					_strings[i].y = 140 + 63.687;
				}
				else{
					_strings[i].y = 140;
				}
				rotateStr(i);
			}
		}
		private function rotateStr(strNum:int):void{
			var linear_easer:Linear = new Linear(0,0);
			var rotater:Rotate3D = new Rotate3D(_strings[strNum]);
			rotater.angleXFrom = 0;
			rotater.angleXTo = 359;
			rotater.repeatCount = 0;
			rotater.repeatDelay = 0;
			rotater.duration = 300;
			rotater.autoCenterTransform = true;
			rotater.startDelay = 0;
			rotater.easer = linear_easer;
			rotater.play();
		}
		public function splitStrings(frac:int, stageW:int):void{
			for(var i:int=0; i<_strings.length; i++){
				if(i < frac){
					_strings[i].visible = true;
					_strings[i].width = stageW/frac;
					_strings[i].x = i*(stageW/frac);
				}else{
					_strings[i].visible = false;
				}
			}
		}
		public function mergeStrings(stageW:int):void{
			for(var j:int=0; j<_strings.length; j++){
				if(j == 0){
					_strings[j].visible = true;
				}else{
					_strings[j].visible = false;
				}
				_strings[j].width = stageW;
				_strings[j].x = 0;
			}
		}
		public function getArr():Array{
			return _strings;
		}
	}
}